package com.funcourse.demo.model;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModelProperty;
import java.util.LinkedList;
import java.util.List;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.index.Indexed;
import org.springframework.data.mongodb.core.mapping.Document;

@Document
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@JsonInclude(JsonInclude.Include.NON_NULL)
public class CompeteRoom {

  @ApiModelProperty("房间id，创建不用填")
  @Id
  String id;

  String roomName;

  @ApiModelProperty("房间号，创建不用填")
  String roomNumber;

  @ApiModelProperty("房间创建者id，创建不用填")
  @Indexed
  String ownerId;

  @ApiModelProperty("房间组织者名称，创建不用填")
  @Indexed
  String organizer;

  @ApiModelProperty("房间题组信息，创建不用填")
  Quiz quiz;

  @ApiModelProperty("房间内用户信息，创建不用填")
  List<UserWithScore> userWithScoreList = new LinkedList<>();

  /**
   * miliseconds http request
   */
  @ApiModelProperty("派发模式截至时间戳毫秒单位")
  @Indexed
  Long deadLine;

  /**
   * miliseconds http request
   */
  @ApiModelProperty("派发模式开始时间戳毫秒单位")
  @Indexed
  Long startTime;

  /**
   * http request
   */
  @ApiModelProperty("房间当前状态，创建不用填")
  RoomStatus roomStatus = RoomStatus.CREATED;

  @ApiModelProperty("现场模式当前答题题目，创建不用填")
  Integer currentQuestionNO = 0;

  @ApiModelProperty("现场模式当前答题题目是否全部作答，创建不用填")
  Boolean questionAllAnswered = false;

  /**
   * http request
   */
  @ApiModelProperty("房间类型：REAL_TIME/COLLECT")
  RoomType roomType = RoomType.REAL_TIME;

  @Indexed
  @ApiModelProperty("组织时间TIMESTAMP")
  Long orgnizedTime;

  String qrCodeUrl;


  public enum RoomStatus {
    CREATED, STARTED, CLOSED;
  }

  public enum RoomType {
    REAL_TIME, COLLECT;
  }

}
